<template>
  <div>
    <h3 class="v-hd3">
      <div class="tit">
        <a href="javascript:;" class="txt" @click.prevent="$router.go(-1)">私信</a>
        <span class="sep">></span>
        <span class="mail">{{$route.query.nickname}}</span>
      </div>
      <a href="#" class="subtit">
        <i class="u-icn-11 icon20"></i>
        清除对话
      </a>
    </h3>
    <div class="n-chat">
      <a href="#" class="loadmore">查看更多消息</a>
      <div class="j-flag">
        <div v-for="(item,index) in msgs" :key="index" style="padding-bottom: 40px;height: auto;overflow: hidden;">
          <div class="date">{{formatDate(item.time)}}</div>
          <div class="itemleft">
            <router-link :to="{name:'UserDetailView',params:{id:item.fromUser.userId,type:1}}" class="ava" :title="$route.query.nickname">
              <img v-lazy="item.fromUser.avatarUrl" alt="">
            </router-link>
            <div class="main">
              <div class="mc">
                <div class="chatbub1">
<!--                  <div class="cnt">-->
<!--                    <p class="s-fc3">用户调研</p>-->
<!--                    <p>云村小伙伴您好！为了给您提供更好的服务，我们发起了用户调研活动，欢迎踊跃回答！</p>-->
<!--                    <div class="sharecnt">-->
<!--                      <div class="cvr">-->
<!--                        <a href="#">-->
<!--                          <img src="http://p1.music.126.net/8JDIfd9dNio5RIpa116tQQ==/109951163293613689.jpg?param=90y60"-->
<!--                               alt="">-->
<!--                        </a>-->
<!--                      </div>-->
<!--                      <div class="info">-->
<!--                        <p class="tiet">-->
<!--                          <a href="#" class="s-fi1">网易云音乐用户调研</a>-->
<!--                        </p>-->
<!--                      </div>-->
<!--                    </div>-->
<!--                    <a href="#" class="cls">x</a>-->
<!--                  </div>-->
                  <div class="cnt">
                    <p v-html="JSON.parse(item.msg).msg.replace(/\n/g,'<br>')"></p>
                  </div>
                  <i class="corr"></i>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="n-chatipt">
      <div class="cmmtipt">
        <div class="holder">
          <textarea class="area"></textarea>
        </div>
        <div class="btns">
          <i class="icn icon-1"></i>
          <i class="icn icon-2"></i>
          <a href="javascript:void(0)" class="u-btn">发送</a>
          <span class="zs">200</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import {formatDate} from "@/utils/formatDate";

export default {
  name: "index",
  data() {
    return {
      msgs: [],
      formatDate:formatDate
    }
  },
  methods: {
    async getSendUserMsg() {
      let result = await this.$API.reqHistoryMsg(this.$route.query.id, this.$store.state.track.user.cookies)
      console.log(result)
      this.msgs = result.data.msgs
    }
  },
  mounted() {
    this.getSendUserMsg()
  }
}
</script>

<style scoped lang="less">
.v-hd3 {
  height: 35px;
  border-bottom: 2px solid #d13030;

  .tit {
    font-size: 14px;
    font-weight: bold;
    line-height: 35px;
    float: left;

    .txt {
      color: #0c73c2;
    }

    .sep {
      margin: 0 10px;
      color: #666;
      font-family: simsun, \5b8b\4f53;
      font-weight: normal;
    }
  }

  .subtit {
    float: right;
    line-height: 35px;
    color: #888;

    .u-icn-11 {
      margin: -2px 5px 0 0;
      width: 13px;
      height: 14px;
      background-position: 0 -284px;
      background-image: url("../../../../assets/icon.png");
    }
  }
}

.n-chat {
  overflow-y: auto;
  padding-right: 40px;
  margin-right: -40px;
  height: 493px;

  .loadmore {
    width: 150px;
    height: 26px;
    display: block;
    line-height: 26px;
    margin: 16px auto -6px;
    border-radius: 13px;
    text-align: center;
    background-color: #c5c5c5;
    color: #fff;
  }

  .j-flag {
    .date {
      height: 14px;
      margin: 0 auto;
      padding: 20px 0 0;
      color: #888;
      text-align: center;
      line-height: 14px;
    }

    .itemleft {
      margin-top: 30px;
      margin-bottom: 30px;

      .ava {
        position: relative;
        float: left;
        width: 50px;
        height: 50px;
        display: block;
        margin-right: -100px;
        img{
          width: 50px;
          height: 50px;
          display: block;
        }
      }

      .main {
        float: right;
        display: inline;
        width: 100%;
        margin: 0 0 0 -66px;

        .mc {
          margin: 0 194px 0 64px;
          zoom: 1;

          &:after {
            clear: both;
            content: '.';
            display: block;
            height: 0;
            visibility: hidden;
          }

          .chatbub1 {
            position: relative;
            padding-left: 9px;
            float: left;
            background-position: 0 0;

            .corr {
              position: absolute;
              top: 15px;
              left: 0;
              width: 9px;
              height: 20px;
              background-image: url("../../../../assets/spriteMsg.png");
            }

            .cnt {
              background-color: #f4f4f4;
              padding: 16px 20px;
              border-radius: 10px;
              line-height: 20px;
              word-break: break-word;

              p {

              }

              .s-fc3 {
                color: #666;
              }

              .sharecnt {
                background: #fff;
                position: relative;
                margin-top: 5px;
                padding: 10px 15px 10px 10px;
                width: 375px;

                .cvr {
                  width: 90px;
                  height: 60px;
                  float: left;
                  margin-right: -100px;

                  a {
                    img {
                      display: block;
                      width: 100%;
                      height: 100%;
                    }
                  }
                }

                .info {
                  margin-left: 105px;
                  display: table;
                  line-height: 21px;
                  min-height: 60px;
                  max-width: 350px;

                  .tiet {
                    display: table-cell;
                    vertical-align: middle;
                    padding-top: 0;
                    margin-left: 0;

                    .s-fi1 {
                      color: #333;
                    }
                  }
                }

              }

              .cls {
                right: 8px;
                //display: none;
                position: absolute;
                top: 5px;
                width: 9px;
                height: 9px;
                text-indent: -999em;
                background-image: url("../../../../assets/spriteMsg.png");
                background-position: -20px 0;
              }

            }

          }
        }
      }
    }
  }

}

.n-chatipt {
  position: relative;
  z-index: 100;
  margin: 0 -40px -30px;
  padding: 16px 40px 12px;
  background: #fcfcfc;
  border-top: 1px solid #f2f2f2;

  .cmmtipt {
    position: relative;
    zoom: 1;

    .holder {
      position: relative;
      zoom: 1;
      padding-right: 14px;

      .area {
        height: 50px;
        display: block;
        width: 100%;
        margin-right: -20px;
        margin: 0;
        padding: 5px 6px 6px;
        border: 1px solid #cdcdcd;
        border-radius: 2px;
        line-height: 19px;
        font-size: 12px;
        color: #333;
        font-family: Arial, Helvetica, sans-serif;
        -webkit-text-size-adjust: none;
        box-sizing: content-box;
        resize: none;
        overflow: auto;
      }
    }

    .btns {
      clear: both;
      padding-top: 10px;

      .icn {
        float: left;
        margin: 0px 10px 0 0;
        cursor: pointer;
        display: inline-block;
        overflow: hidden;
        vertical-align: middle;
        background-image: url(../../../../assets/icon.png);
      }

      .icon-1 {
        width: 18px;
        height: 18px;
        background-position: -40px -490px;
      }

      .icon-2 {
        float: left;
        margin: 0px 10px 0 0;
        cursor: pointer;
      }

      .u-btn {
        float: right;
        width: 46px;
        height: 25px;
        background-position: -84px -64px;
        background-image: url(../../../../assets/button.png);

        color: #fff;
        text-align: center;
        line-height: 25px;
      }

      .zs {
        float: right;
        margin-right: 10px;
        line-height: 25px;
        color: #999;
      }
    }
  }
}
</style>